﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理页面</title>
<link href="{webroot}theme/admin/css/layout.css" rel="stylesheet" type="text/css" />
<link href="{webroot}theme/admin/css/iframe.css" rel="stylesheet" type="text/css" />
<link href="{webroot}theme/admin/css/iconfont.css" rel="stylesheet" type="text/css" />
<link href="{webroot}lib/css/jquery.colorpicker.css" rel="stylesheet" type="text/css" />
<script src="{webroot}lib/js/jquery.js"></script>
<script src="{webroot}lib/js/jquery-migrate-1.1.0.min.js"></script>
<script src="{webroot}lib/js/jquery-ui.min.js"></script>
<script src="{webroot}theme/admin/js/jquery.layout-latest.min.js"></script>
<script src="{webroot}lib/js/jquery.uploader.js"></script>
<script src="{webroot}lib/tips/jquery.tips.js"></script>
<script src="{webroot}lib/validator/jquery.validator.js"></script>
<script src="{webroot}lib/validator/zh_CN.js"></script>
<script src="{webroot}lib/js/jquery.livequery.js"></script>
<script src="{webroot}lib/js/jquery.colorpicker.js"></script>
<script src="{webroot}theme/admin/js/admin.js"></script>
<script src="{webroot}lib/dialog/artdialog.js"></script>
<!--[if lt IE 9]>
<script src="{webroot}lib/js/html5.js"></script>
<![endif]-->
<script>



var myLayout;
$(function(){
		$(".selectFile").live("click", function() {
        var a = $(this).attr("config"),
            b = a.split(":"),
            c = b[0],
            d = b[1],
            e = b[2],
            f = b[3];
        top.dialog({
            title: "文件上传",
            content: "<iframe src='/admin/upload.asp?filetype=" + d + "&cid=" + e + "&classid=" + f + "' width='560' height='400' frameborder='0' id='niceupload'></iframe>",
            padding: "10px",
            ok: function() {
                var a = $("#att-status", window.top.document.getElementById("niceupload").contentWindow.document).html();
                if (null != a) {
                    var b, d,temp;
                    b = a.substring(0, 1), d = a.substring(1), $("input[id=" + c + "]").attr("value", d)
				 
                }
            },
            cancel: !0
        }).showModal()
    })
myLayout=$("body").layout({north__spacing_open:0,south__spacing_open:0,east__spacing_open:0,east__minSize:250,east__initClosed:{sdcms[sys_optional]},resizable:false});
	$(".ui-layout-toggler-east").click(function(){$(".right_subject span").fadeToggle(300);});
	$(".right_subject span a").click(function(){myLayout.toggle('east');$(this).parent().fadeToggle(100)});
	UE.getEditor('t2',editorOption);
	{editor_int}
	$("#golike .del").live("click",function(){$(this).parent().remove();});
	$("#s0").click(function(){
		if($(this).attr("checked")){
		$("#c0").attr("value","font-weight:bold;");
		}else{$("#c0").attr("value","");}
	})
	$("#s1").click(function(){
		if($(this).attr("checked")){
		$("#c1").attr("value","font-style:italic;");
		}else{$("#c1").attr("value","");}
	})
	//beigin
	var $addInput=$("#addInput");
	var $tableid=$("#voteitem");
	var $addInput=$("#addInput");
	$addInput.click(function(){
		var sonnum=$("#voteitem li").size();
		var textValueTrHtml='<li><input type="text" name="t29" id="t29_'+sonnum+'" size="15" maxlength="50" class="ip" value="附件'+(sonnum+1)+'" onfocus="if(this.value==&quot;附件'+(sonnum+1)+'&quot;)this.value=&quot;&quot;" onblur="if(this.value==&quot;&quot;)this.value=&quot;附件'+(sonnum+1)+'&quot;" data-rule="项目名称:required;" /><input type="text" name="t30" id="t30_'+sonnum+'" size="40" maxlength="255" class="ip" data-rule="下载地址:required;" /><input type="button" value="本地上传" config="t30_'+sonnum+':2:0:1" class="bnt_save selectFile"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a><span for="t30_'+sonnum+'" class="msg-box"></span></li>';
	   sonnum=$("#voteitem li").size();
	   if(sonnum==10)
	   {
		   $.fn.tips({content:'最多只能添加10个'});
		   return false;
	   }
	   else
	   {
		   $tableid.append(textValueTrHtml);
		 }
	})
	
	$(".leftarr").live("click", function() {
		var $ValueTr = $(this).parent();
		var $PrevTr = $ValueTr.prev("li");
		var PrevTrIndex = $("#voteitem li").index($PrevTr);
		$PrevTr.insertAfter($ValueTr);
	});
	
	$(".rightarr").live("click", function() {
		var $ValueTr = $(this).parent();
		var $NextTr = $ValueTr.next("li");
		if ($NextTr.length > 0) {
			$NextTr.insertBefore($ValueTr);
		}
	});
	
	$(".delarr").live("click", function() {
		if (confirm("\u60a8\u786e\u5b9a\u8981\u5220\u9664\u5417\uff1f") == true) {
		var sonnum=$("#voteitem li").size()
		 $(this).parent().remove();
		}
	});
	
	var previewHTML='';
	var dnum=1;
	
	

	//begin
	//增加
	$("#addImage").click(function()
	{
		var html="";
			html+='<dl class="move">'
			html+='  <dt><b>图片地址：</b><textarea id="picurl"></textarea><div>一行一个图片地址</div></dt>'
			html+='</dl>'
			top.dialog({
			title:'远程图片',
			content:html,
			ok:function(){
				var t0=window.top.$("#picurl")[0].value;
				if(t0=="")
				{
					alert("\u56fe\u7247\u5730\u5740\u4e0d\u80fd\u4e3a\u7a7a");
					$("#picurl")[0].focus();
					return false
				}
				else
				{
					var picarr;
					picarr=t0.split("\n");
					for(i=0;i<picarr.length;i++){
						var ImageHtml='<li>'
                            ImageHtml+='    <div class="img">'
                            ImageHtml+='        <img src="'+picarr[i]+'" width="100" height="80" border="0">'
                            ImageHtml+='    </div>'
                            ImageHtml+='    <div class="pic_other">'
                            ImageHtml+='        <div class="row-fluid">'
                            ImageHtml+='            <div class="span2"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a></div>'
                            ImageHtml+='       </div>'
                            ImageHtml+='   </div>'
							ImageHtml+='   <input type="hidden" name="t40" value="'+picarr[i]+'" />'
                            ImageHtml+='</li>'
							$("#ImageArea").prepend(ImageHtml);
					}
				}
								
			},
			cancel:true 
		}).showModal();
	}
	)
	//左移
	$("#ImageArea .leftarr").live("click",function(){
		var $Imageli=$(this).parent().parent().parent().parent();
		var $ImagePrevli=$Imageli.prev("li");
		if($ImagePrevli.length>0){$ImagePrevli.insertAfter($Imageli);}
	});
	
	//右移
	$("#ImageArea .rightarr").live("click",function(){
		var $Imageli=$(this).parent().parent().parent().parent();
		var $ImageNextli=$Imageli.next("li");
		if($ImageNextli.length>0){$ImageNextli.insertBefore($Imageli);}
	});
	
	//删除
	$("#ImageArea .delarr").live("click",function(){
		var thispic=$(this).parent().parent().parent().parent();
			top.dialog({
				content:'\u60a8\u786e\u5b9a\u8981\u5220\u9664\u5417',
				ok:function(){thispic.remove();},
				cancel:true 
			}).showModal();
	});
	//清空
	$("#clearImage").live("click",function() {
		var thispic=$("#ImageArea li");
			top.dialog({
				content:'\u786e\u5b9a\u8981\u6e05\u7a7a\uff1f',
				ok:function(){thispic.remove();},
				cancel:true 
			}).showModal();
	});
	
	var previewHTML='';
    $('#selectFile').uploader({
        action:'sd_upload.asp?act=json&classid=1&admin_id={adminid}&loginbase={admin_loginbase}&loginkey={admin_loginkey}',
        name: "file",
        formData:{},
		mode: 'flash',
        multiple:true,
        auto:true,
        fileSizeLimit: '{sdcms[upmaxsize]}KB',
        fileTypeDesc: '选择图片',     
        fileTypeExts: 'jpg,gif',
		onProgress: function(e){
            $.fn.tips({type:'loading',content:'文件上传中，请稍后'});
        },
		/*onSelected:function(filelist){
			filelist.length=5;
        },*/
		onError:function(e){
             $.fn.tips({content:e.name});
        },
        onSuccess:function(e){
			data=jQuery.parseJSON(e.data);
            if(data.status=="y")
			{
				var ImageHtml='<li>'
					ImageHtml+='    <div class="img">'
					ImageHtml+='        <img src="'+data.info+'" width="100" height="80" border="0">'
					ImageHtml+='    </div>'
					ImageHtml+='    <div class="pic_other">'
					ImageHtml+='        <div class="row-fluid">'
					ImageHtml+='            <div class="span2"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a></div>'
					ImageHtml+='       </div>'
					ImageHtml+='   </div>'
					ImageHtml+='   <input type="hidden" name="t40" value="'+data.info+'" />'
					ImageHtml+='</li>'
				previewHTML+=ImageHtml;
			}else{$.fn.tips({content:data.info});}
        },
        onAllComplete:function(){
            if(previewHTML){
                $('#ImageArea').prepend(previewHTML);
				$.fn.tips({type:'ok',content:'上传完成'});
                previewHTML='';
            }
           
        }
    }); 
	//over		

})
</script>
</head>
<body>

<div class="ui-layout-north">
    <div class="right_subject"><span><a href="javascript:;">关闭选填项目</a></span>当前位置：内容 > <a href="sd_content.asp?classid={classid}">{catename}</a> > <a href="?classid={classid}&act=edit&id={id}&page={page}&where={where}&keyword={keyword}">修改内容</a></div>
</div>
<form class="formname" method="post">
<div class="ui-layout-center">
    <div class="table_form">
        <div class="form_group">
            <div class="form_txt">标题：</div>
            <div class="form_input"><input type="text" name="t0" id="t0" size="50" maxlength="255" value="{data(0,0)}" class="ip" data-rule="标题:required;" />
            {dim style:style=data(11,0)}
    <input name="s0" type="checkbox" id="s0" {if instr(style,"font-weight:bold;")>0}checked{/if} /><label for="s0">粗体</label>
    <input name="s1" type="checkbox" id="s1" {if instr(style,"font-style:italic;")>0}checked{/if} /><label for="s1">斜体</label>
    <input type="hidden" name="c0" id="c0" {if instr(style,"font-weight:bold;")>0}value="font-weight:bold;"{/if} />
    <input type="hidden" name="c1" id="c1" {if instr(style,"font-style:italic;")>0}value="font-style:italic;"{/if} />
    <input type="hidden" name="s2" id="s2" {if instr(style,"color:")>0}value="{left(right(style,8),7)}"{/if} />
    <img src="{webroot}lib/images/colorpicker.gif" title="标题颜色" align="absmiddle" id="color" {if instr(style,"color:")>0} style="background:{left(right(style,8),7)}"{/if} /><span for="t0" class="msg-box"></span></div>
        </div>
        <div class="form_group">
            <div class="form_txt">缩略图：</div>
            <div class="form_input"><input type="text" name="t6" id="t6" size="50" maxlength="255" value="{data(3,0)}" class="ip" /><input type="button" value="上传" config="t6:1:{id}:1"  class="bnt bnt_save" /></div>
        </div>        
        {if isarray(field_data)}
        {for i=0 to ubound(field_data,2)}
        <%dim dvalue:dvalue=rsshow(field_data(0,i))%>
        <div class="form_group">
            <div class="form_txt">{field_data(1,i)}：</div>
            <div class="form_input">{get_self_field(field_data(0,i),field_data(1,i),field_data(2,i),field_data(3,i),field_data(5,i),field_data(7,i),field_data(8,i),field_data(9,i),dvalue,field_data(11,i),id,field_data(6,i),1)}</div>
        </div>
        {/for}
        {/if}
        
        <div class="form_group">
            <div class="form_txt">产品图片：</div>
            <div class="form_input">
                <input type="button" value="本地上传" class="bnt_save" id="selectFile"><input type="button" value="网络图片" class="bnt_normal" id="addImage"><input type="button" value="清空产品图片" class="bnt_normal" id="clearImage">
                <ul class="piclist" id="ImageArea">
                {for i=0 to ubound(piclist)}
                <li>
                    <div class="img">
                        <img src="{piclist(i)}" width="100" height="80" border="0">
                    </div>
                    <div class="pic_other">
                        <div class="row-fluid">
                            <div class="span2"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a></div>
                       </div>
                   </div>
                   <input type="hidden" name="t40" value="{piclist(i)}" />
                </li>
                {/for}
                </ul>
            </div>
        </div>
        
        
        <div class="form_group">
            <div class="form_txt">下载地址：</div>
            <div class="form_input">
          <input type="button" value="添加一条" class="bnt_normal" id="addInput">
               {dim wayarr:wayarr=split(rsshow[downway],",")}
               {dim urlarr:urlarr=split(rsshow[downurl],",")}
               <ul class="voteitem" id="voteitem">
               {for i=0 to ubound(wayarr)}
               <li><input type="text" name="t29" id="t29_{i}" size="15" maxlength="50" class="ip" value="{wayarr(i)}" data-rule="项目名称:required;" /><input type="text" name="t30" id="t30_{i}" size="40" maxlength="255" value="{urlarr(i)}" class="ip" data-rule="下载地址:required;" /><input type="button" value="本地上传" config="t30_{i}:2:0:1" class="bnt_save selectFile"><a href="javascript:;" class="leftarr iconfont">&#xe60a;</a><a href="javascript:;" class="rightarr iconfont">&#xe608;</a><a href="javascript:;" class="delarr iconfont">&#xe602;</a><span for="t30_{i}" class="msg-box"></span></li>
               {/for}
               </ul>
            </div>
        </div>
        
        <div class="form_group">
            <div class="form_txt">描述：</div>
            <div class="form_input"><textarea name="t2" id="t2" style="width:98%;">{sdcms.enhtml(rsshow[content])}</textarea></div>
        </div>
        <div class="form_group">
            <div class="form_txt">Tags：</div>
            <div class="form_input"><input type="text" name="t1" id="t1" size="40" maxlength="255" value="{data(12,0)}" class="ip" /><input type="button" value="根据标题提取" config="t0:t1:{classid}" class="bnt_tags bnt_save" /><input type="hidden" name="t1_0" size="80" maxlength="255" value="{data(12,0)}" />　<span>支持空格和英文逗号分隔</span></div>
        </div>
        <div class="form_group">
            <div class="form_txt">META关键字：</div>
            <div class="form_input"><input type="text" name="t4" size="50" maxlength="255" value="{data(1,0)}" class="ip" /></div>
        </div>
        <div class="form_group">
            <div class="form_txt">META描述：</div>
            <div class="form_input"><input type="text" name="t5" size="50" maxlength="255" value="{data(2,0)}" class="ip" /></div>
        </div>
    </div>
</div>
<div class="ui-layout-east">
    <div class="table_form">
        <div class="form_li">
            <div class="form_txt">作者：</div>
                <div class="form_input"><input type="text" name="t7" size="25" maxlength="50" value="{data(13,0)}" class="ip" /></div>
            </div>
            <div class="form_li">
                <div class="form_txt">来源：</div>
                <div class="form_input"><input type="text" name="t8" id="t8" size="12" maxlength="50" value="{data(14,0)}" class="ip" /> <select onChange="$('#t8').val(this.value)" class="ip">
      <option value="">选择</option>
      <option value="未知">未知</option>
      <option value="原创">原创</option>
      <option value="转载">转载</option>
    </select></div>
            </div>
            <div class="form_li">
                <div class="form_txt">人气：</div>
                <div class="form_input"><input type="text" name="t9" size="25" maxlength="10" value="{data(4,0)}" class="ip" /></div>
            </div>
            <div class="form_li">
                <div class="form_txt">阅读积分：</div>
                <div class="form_input"><input type="text" name="t16" size="25" maxlength="10" value="{data(15,0)}" class="ip" /></div>
            </div>
            <div class="form_li">
                <div class="form_txt">文件名称：</div>
                <div class="form_input"><input name="t17" type="text" size="25" maxlength="50" value="{data(16,0)}" class="ip" /></div>
            </div>
            <div class="form_li">
                <div class="form_txt">状态：</div>
                <div class="form_input">
                <input type="checkbox" name="t10" id="t10" value="1" {if data(5,0)=1}checked{/if} /><label for="t10">发布</label>
           <input type="checkbox" name="t11" id="t11" value="1" {if data(6,0)=1}checked{/if} /><label for="t11">推荐</label>
           <input type="checkbox" name="t12" id="t12" value="1" {if data(7,0)=1}checked{/if} /><label for="t12">置顶</label>
           <input type="checkbox" name="t13" id="t13" value="1" {if data(8,0)=1}checked{/if} /><label for="t13">允许评论</label></div>
            </div>
            <div class="form_li">
                <div class="form_txt">发布日期：</div>
                <div class="form_input"><input name="t14" type="text" value="{data(9,0)}" size="25" maxlength="50" class="ip" /></div>
            </div>
            <div class="form_li">
                <div class="form_txt">相关内容：</div>
                <div class="form_input"><input type="text" id="key" size="15" class="ip" value="请输入关键字" onFocus="if(this.value==defaultValue)this.value=''" onBlur="if(this.value=='')this.value=defaultValue" config="{classid}:{id}" /><input type="button" value="查找" id="likesearch" class="bnt_save" />
                <ul id="golike">{if likeid<>"0"}{sdcms:rs table="sd_content" where="id in([likeid])"}<li><span class="del"></span><input type="hidden" name="like" value="{$rs[id]}" />{sdcms.cutstr($rs[title],70,1)}</li>{/sdcms:rs}{/if}</ul>
                </div>
            </div>
    </div>
</div>
<div class="ui-layout-south">
    <div class="form_bnt"><input type="submit" value="保存" class="bnt_save"><input type="button" value="返回" class="bnt_normal goback"></div>
</div>
</form>
<script>
$(".formname").validator(
	{
		stopOnError:true,
        theme:'yellow_right_effect',
		ignore:':hidden',
		beforeSubmit:function(){$("input[type='submit']").attr("disabled",true);},
		valid:function(form)
		{
			if($("input[name=t40]").length<=0)
			{
				$.fn.tips({content:"请至少添加或上传一张组图"});
				$("input[type='submit']").attr("disabled",false);
				return false;
			}
			
			if($("input[name=t30]").length<=0)
			{
				$.fn.tips({content:"请至少添加一个下载地址"});
				$("input[type='submit']").attr("disabled",false);
				return false;
			}
			
			$.fn.tips({type:'loading',content:'数据提交中'});
			$.ajax(
			{
				url:"?act=editdb&classid={classid}&id={id}",
				type:"post",
				data:$(form).serialize(),
				success:function(data){
					data=jQuery.parseJSON(data);
					if(data.status=="n"){$.fn.tips({type:"warn",content:data.info});$("input[type='submit']").attr("disabled",false);}
					else
					{
						var arr=data.info;
						arr=arr.split(":");
						var id=arr[0];
						var info=arr[1];
						var url="sd_content.asp?classid={classid}&sta={sta}&nat={nat}&order={order}&keyword={keyword}&page={page}";
						{if webmode=3}
						if($("#t10").attr("checked")!=undefined)
						{
							{if sdcms.getsys("htmlhome") or sdcms.getsys("htmlclass") or sdcms.getsys("htmlcontent")}
							$.fn.tips.close();
							top.dialog({id:"html",title:"正在生成相关数据",padding:0,content:"<div id='html_staus'></div>",cancel:false}).showModal();
							var staus=true;
							{if sdcms.getsys("htmlhome")}
							staus=false;
							staus=auto_home({adminid},"{admin_loginbase}","{admin_loginkey}")
							{/if}
							{if sdcms.getsys("htmlclass")}
							var parentid="{parentid}";
							var arr=parentid.split(",");
							for(i=0;i<arr.length;i++)
							{
								staus=false;
								staus=auto_class({adminid},"{admin_loginbase}","{admin_loginkey}",{sdcms.getsys("htmltotal")},arr[i])
							}
							{/if}
							{if sdcms.getsys("htmlcontent")}
							staus=false;
							staus=auto_content({adminid},"{admin_loginbase}","{admin_loginkey}",id,1)
							{/if}
							if(staus){setTimeout(function(){location.href=url},1500);}
							{else}
							$.fn.tips({type:"ok",content:info});
							setTimeout(function(){location.href=url},1000)
							{/if}
						}
						else
						{
							$.fn.tips({type:"ok",content:info});
							setTimeout(function(){location.href=url},1000)
						}
						{else}
							$.fn.tips({type:"ok",content:info});
							setTimeout(function(){location.href=url},1000)
						{/if}
					}
				}
			});
		},
		invalid:function(){$("input[type='submit']").attr("disabled",false);}
	}
);
</script>
</body>
</html>